//
//  SISSMinePassengerCell.m
//  SISSAPP
//
//  Created by 优房网 on 2017/5/23.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSMinePassengerCell.h"


@interface SISSMinePassengerCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *detailLabel;
@property (weak, nonatomic) IBOutlet UILabel *tagLabel;

@end
@implementation SISSMinePassengerCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setPassengerModel:(SISSPassengerResourceModel *)passengerModel {
    _passengerModel = passengerModel;
    
    UIColor *color = passengerModel.read == 1 ? [UIColor grayColor] : COLOR(0x334A60);
    self.nameLabel.textColor = color;
    self.detailLabel.textColor = color;
    
    NSString *tagStr;
    UIColor *tagColor;
    switch (passengerModel.business_status) {
        case 0:
            tagStr = @"等待确认";
            tagColor = COLOR(0xAEC1D9);
            break;
            
        case 1:
            tagStr = @"已确认";
            tagColor = COLOR(0xff334f);
            break;
            
        case 2:
            tagStr = @"已拒绝";
            tagColor = COLOR(0xFF1F1D);
            break;
            
        default:
            break;
    }
    
    self.tagLabel.textColor = tagColor;
    self.tagLabel.text = tagStr;
    
    if (passengerModel.demandType != 2) {
        
        // 根据身份证判断显示 先生、女士
        NSString *fisrtName = [passengerModel.buyer_name substringToIndex:1];
        NSInteger idNum = [[passengerModel.idNumber substringWithRange:NSMakeRange(passengerModel.idNumber.length - 2, 1)] integerValue];
        
        NSString *genderStr = (idNum % 2) == 0 ? @"女士" : @"先生";
        self.nameLabel.text = [NSString stringWithFormat:@"%@%@  %@",fisrtName,genderStr,@"求购"];
    } else {
        self.nameLabel.text = [NSString stringWithFormat:@"%@  %@",passengerModel.buyer_name,@"求购"];
    }

    self.detailLabel.text = [NSString stringWithFormat:@"%0.f-%0.f万 | %@-%@ | %@",passengerModel.minPrice,passengerModel.maxPrice,passengerModel.region,passengerModel.regionDetail,passengerModel.houseType];
}

- (void)setPassengerCooperationModel:(SISSPassengerCooperationModel *)passengerCooperationModel {
    
    _passengerCooperationModel = passengerCooperationModel;
    
    self.tagLabel.backgroundColor = COLOR(0xFF1F1D);
    self.tagLabel.textColor = [UIColor whiteColor];
    self.tagLabel.layer.cornerRadius = 6;
    self.tagLabel.layer.masksToBounds = YES;
    self.tagLabel.text = passengerCooperationModel.count ? [NSString stringWithFormat:@" %zd ",passengerCooperationModel.count] : @"";
    
    self.nameLabel.text = [NSString stringWithFormat:@"%@  %@",passengerCooperationModel.name,@"求购"];
    self.detailLabel.text = [NSString stringWithFormat:@"%0.f-%0.f万 | %@-%@ | %@",passengerCooperationModel.min_price,passengerCooperationModel.max_price,passengerCooperationModel.region,passengerCooperationModel.region_detail,passengerCooperationModel.house_type];
}

@end
